﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace Azku.Common
{
    [Serializable]
    public class User
    {
        public string UserName { get; set; }
        public string UserPwd { get; set; }
        public string UserGroupName { get; set; }
        public DateTime LastUpdateTime { get; set; }
        public IPEndPoint UserIPEndPoint { get; set; }
    }


    [Serializable]
    public class UserCollection : System.Collections.CollectionBase
    {
        public void Insert(User user)
        {
            base.OnInsert(this.Count, user);
        }
        public void Update(User user)
        {
            
        }
        public void Delete(User user)
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].UserName.ToLower() == user.UserName.ToLower())
                {
                    this.RemoveAt(i);
                }
            }
        }

        public User this[int index]
        {
            get
            {
                return (User)this.List[index];
            }
        }
        public User this[string name]
        {
            get
            {
                User m_User = null;
                for (int i = 0; i < Count; i++)
                {
                    if (this[i].UserName.ToLower() == name.ToLower())
                    {
                        m_User = this[i];
                    }
                }
                return m_User;
            }
        }
    }
}
